import { CopyControllerBase } from "./CopyControllerBase";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { EPublicCommand } from "../../../../../Message/Command/EPublicCommand";
import { MaterialCopyInfoPanel } from "../MaterialLV105Copy/MaterialCopyInfoPanel";
import { TCopy } from "../../../../../Message/Db/Tables/TCopy";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SCopyMaterialInfo } from "../../../../../Message/Public/SCopyMaterialInfo";
//class MaterialCopyController
    
    export  class MaterialCopyController extends CopyControllerBase
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ initServer(): void
        {
            super.initServer();
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCopy105MaterialKillBoss, this.onKillBossHandler);
            return;
        }

        public get infoPanel(): MaterialCopyInfoPanel
        {
            if (this._infoPanel == null) 
            {
                this._infoPanel = new MaterialCopyInfoPanel();
            }
            return this._infoPanel;
        }

        public /* override */ enterCopy(arg1: TCopy): void
        {
            super.enterCopy(arg1);
            this.infoPanel.show();
            this.infoPanel.showPanel();
            this.infoPanel.title = arg1.name;
            this.infoPanel.updateByCopyInfo(arg1);
            if (this._info) 
            {
                this.infoPanel.updateByTempleInfo(this._info);
            }
            return;
        }

        public /* override */ leaveCopy(): void
        {
            super.leaveCopy();
            if (this._infoPanel) 
            {
                this._infoPanel.hide();
            }
            this._info = null;
            return;
        }

        /* internal  */onKillBossHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCopyMaterialInfo;
            this._info = loc1;
            if (this._infoPanel) 
            {
                this._infoPanel.updateByTempleInfo(loc1);
            }
            return;
        }

        /* internal */ /* var */_infoPanel: MaterialCopyInfoPanel;

        /* internal */ /* var */_info: SCopyMaterialInfo;
    }
